/***********************************************************************
 * Module:  PersonDto.java
 * Author:  Vanil
 * Purpose: Defines the Class PersonDto
 ***********************************************************************/
package personal;
import db.dao.PersonDao;
import db.dto.PersonDto;
import db.exceptions.PersonDaoException;
import db.factory.PersonDaoFactory;
import db.jdbc.PersonDaoImpl;
import org.simpleframework.xml.Root;

@Root
public abstract class Person {


   public PersonDto dto;
   static PersonDao dao;
    public Person(PersonDto dto) {
        this.dto = dto;
        dao = PersonDaoFactory.create() ;
    }
    public Person() {
           // idPerson = personMaxId++;
    }
   
    public void setIdPerson(int idPerson) {
        this.dto.setIdPerson(idPerson);
    }
    public int getIdPerson() {

        return dto.getIdPerson();
    }

    public String getLogin() {
        return dto.getLogin();
    }

    public void setLogin(String login) {
        this.dto.setLogin(login);
    }

    public void setName(String name) {
        dto.setName(name);

    }
    public void updateUpload() throws PersonDaoException {
        dao.update(this.dto.getIdPerson(),dto);
    }
    public void setPassword(String password) throws PersonDaoException {
        dto.setPassword(password);
    }

    public String getName() {
        return dto.getName();

    }

    public String getPassword() {
        return dto.getPassword();
    }

    @Override
    public boolean equals(Object obj) {
        if(this.dto!=null&&dto.getIdPerson()==((Person)obj).getIdPerson())
        {
            return true;
        }
        else return false;
    } /** @pdOid 1067f16f-951e-4553-8a38-0c7d8534e696 */

}